package com.henghai.zhenxuan.ui.page.adapter;

import android.content.Context;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.henghai.zhenxuan.data.bean.MyHarvestBean;
import com.henghai.zhenxuan.databinding.AdapterMyharvestItemBinding;
import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;

public class MyHarvestAdapter extends SimpleDataBindingAdapter<MyHarvestBean, AdapterMyharvestItemBinding> {
    private OnItemBtClickListener listener;
    public MyHarvestAdapter(Context context) {
        super(context, com.henghai.zhenxuan.R.layout.adapter_myharvest_item, DiffUtils.getInstance().getMyHarvestItemCallback());
    }

    @Override
    protected void onBindItem(AdapterMyharvestItemBinding binding, MyHarvestBean item, RecyclerView.ViewHolder holder) {
        binding.setHarvest(item);
        binding.harvesTag.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onItemDelClick(item,holder.getBindingAdapterPosition());
            }
        });
    }
    public void setListener(OnItemBtClickListener listener) {
        this.listener = listener;
    }

    public interface OnItemBtClickListener {
        void onItemDelClick(MyHarvestBean bean, int postion);
    }
}
